package com.itheima.springbootinit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Helloworid {
    @Value("${parson.name}")
    private String name;
    @Value("${name}")
    private String name1;
    @Value("${parson1.name}")
    private String name2;
    @Value("${address[0]}")
    private String name3;
    @Value("${address1[1]}")
    private String name4;
    @Autowired
    private Environment env;
    @Autowired
    private parson parson;


    @RequestMapping("/hello")
    public String hello() {
        return "hello  spring    boot";
    }

    @RequestMapping("/hello2")
    public String hello2() {
//        System.out.println(name);
//        System.out.println(name1);
//        System.out.println(name2);
//        System.out.println(name3);
//        System.out.println(name4);
//        System.out.println(env.getProperty("add.name"));
//        System.out.println(env.getProperty("msg1"));
//        System.out.println(env.getProperty("msg2"));
        System.out.println(parson);
        String[] address = parson.getAddress();
        for (String s : address) {
            System.out.println(s);
        }


        return "hello  spring    boot";
    }
}
